Notes on small grub reinstall to fix booting

hope it doesn't happen again...

Home About Projects Blog Games Contact Support

An Alpine Linux edge kernel upgrade (or another update, maybe only the grub package) broke grub booting sometime in the past few weeks, between lts kernels 6.6.8-6.6.11. Thankfully only needed to reinstall/configure grub to fix. So this page is if I have to do that again, but hopefully not.

Used a spare usb with alpine "live" environ (or can use ubuntu or anything else).

The fix ended up being this, with my broken alpine partition at /dev/nvme0n1p3, and /boot partition at /dev/nvme0n1p1. Change as needed.

Also assuming grub has been used before and the 'grub' package is installed from e.g. doas apk add grub. You may also need efibootmgr: doas apk add efibootmgr.

In root user of fresh alpine live install usb:

mkdir mnt
mount /dev/nvme0n1p3 mnt/

Needed filesystems for grub-install, although maybe only dev is needed? Didn't really check:

mount --rbind /dev/ mnt/dev
mount --rbind /proc/ /mnt/proc
mount --rbind /sys/ /mnt/sys

Switch to bad partition

chroot mnt/

In chrooted alpine install:

mount /dev/nvme0n1p1 /boot 
grub-install \
--target=x86_64-efi \
--bootloader-id=alpine \
--efi-directory=/boot/efi

After doing that, I exit-ed and reboot-ed, and grub and alpine booted up just fine.